package com.example.demo;

import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * ClassName: JDBCUtil
 * Package: com.example.demo
 * Description: @Version 1.0
 */
public class JDBCUtil {
    public static Connection getConnection() throws ClassNotFoundException, SQLException {
        Class.forName(PropertiesUtil.get("driver"));
        Connection connection= DriverManager.getConnection(PropertiesUtil.get("url"),PropertiesUtil.get("username"),PropertiesUtil.get("password"));
        return connection;
    }

    public static void close(AutoCloseable obj){
        if(obj!=null){
            try {
                obj.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

}
